/**
 * 
 */
package net.cobra.hibernate;

import junit.framework.TestCase;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * @author Conor Lawler
 *
 */
public class WriteToDbTest extends TestCase {

	private SessionFactory sessionFactory = null;
	
	@Override
	protected void setUp() throws Exception{
		// A SessionFactory is set up once for an application
		sessionFactory = new Configuration().configure().buildSessionFactory();
	}
	
	@Override
	protected void tearDown() throws Exception{
		if(sessionFactory!=null)
			sessionFactory.close();
	}
	
	public void testBasicUsage(){
		Session session = sessionFactory.openSession();
		session.beginTransaction();
		Operative ss = new Operative("Storm Shadow", "Ninja Warrior", "Tommy Arashikage");
		session.save(ss);
		session.getTransaction().commit();
		session.close();
	}
}
